- Why RMarkdown (Rmd)?
- What can you do with Rmd?
- Getting started
- The basics
06 Jul 2021
Documents
Presentations (like this one!)
Other stuff
library(crimedata) library(plotly) library(tidyverse)
crime_data <- get_crime_data()
dplyr (Wickham et al. 2020)crime_data %>% filter(city_name == "Austin" & offense_against == "property") %>% group_by(offense_group) %>% summarise(count = n()) %>% ungroup() %>% arrange(desc(count)) %>% slice_head(n = 3)
## # A tibble: 3 x 2 ## offense_group count ## <fct> <int> ## 1 larceny/theft offenses 304 ## 2 destruction/damage/vandalism of property (except arson) 62 ## 3 fraud offenses (except counterfeiting/forgery and bad checks) 56
ggplot2 (Wickham 2016)fig <- crime_data %>% filter(city_name == "Austin" & offense_against == "property") %>% ggplot(mapping = aes(x = date_single, fill = offense_group)) + geom_histogram(bins = 52) print(fig)
Or make it interactive with plotly (Sievert 2020)
ggplotly(fig)
Ashby, Matthew P. J. 2018. “Studying Crime and Place with the Crime Open Database.” https://doi.org/10.31235/osf.io/9y7qz.
Sievert, Carson. 2020. Interactive Web-Based Data Visualization with r, Plotly, and Shiny. Boca Raton, FL: CRC Press, Taylor; Francis Group.
Wickham, Hadley. 2016. Ggplot2: Elegant Graphics for Data Analysis. Cham: Springer.
Wickham, Hadley, Romain François, Lionel Henry, and Kirill Müller. 2020. Dplyr: A Grammar of Data Manipulation. https://CRAN.R-project.org/package=dplyr.